<?php

/**
 * XHTML_Link, xhtml_lib
 * 
 * This file contains the source code for the XHTML_Link class.
 * @author Fernando Jimenez Mocobono <fjmcool@gmail.com>
 * @version 0.1
 * @package xhtml_lib
 */

include_once "XHTML_Common_Element.php";

/**
 * The XHTML_Link class is a handler for the link xhtml-strict tag as a part 
 * of a xhtml-strict php-handler implementation.
 */
class XHTML_Link extends XHTML_Common_Element {
    
    // xhtml attributes
    
    /**
     * Character encoding of the target URI. Default value is "ISO-8859-1"
     *
     * @var string
     */
    protected $charSet;
    
    /**
     * Target URI of the resource.
     *
     * @var string
     */
    protected $href;
    
    /**
     * Base language of the target URI.
     *
     * @var string
     */
    protected $hrefLang;
    
    /**
     * MIME type of the target URI.
     * i.e.: text/css, text/javascript, image/gif.
     *
     * @var string
     */
    protected $type;
    
    /**
     * Relationship between the current document and the targeted document.
     * Valid values: alternate, appendix, bookmark, chapter, contents, 
     * copyright, glossary, help, home, index, next, prev, section, start, 
     * stylesheet, subsection.
     *
     * @var string
     */
    protected $rel;
    
    /**
     * Relationship between the targeted document and the current document.
     * Valid values: alternate, appendix, bookmark, chapter, contents, 
     * copyright, glossary, help, home, index, next, prev, section, start, 
     * stylesheet, subsection.
     *
     * @var string
     */
    protected $rev;
    
    /**
     * Device that will display the document.
     * Valid values: all, braille, print, projection, screen, speech.
     *
     * @var string
     */
    protected $media;
    
    
    //Methods
    
    /**
     * Constructs a XHTML_Link object.
     */
    function __construct()
    {
        $this->charset = "ISO-8859-1";
    }
    
    /**
     * Sets the character encoding of the target URI.
     *
     * @param string $charSet
     */
    function setCharSet($charSet)
    {
        $this->charSet = $charSet;
    }
    
    /**
     * Gets the character encoding of the target URI.
     *
     * @return string
     */
    function getCharSet()
    {
        return $this->charSet;
    }
    
    /**
     * Sets the target URI of the resource.
     *
     * @param sets $href
     */
    function setHref($href)
    {
        $this->href = $href;
    }
    
    /**
     * Gets the target URI of the resource.
     *
     * @return unknown
     */
    function getHref()
    {
        return $this->href;
    }
    
    /**
     * Sets the base language of the target URI.
     *
     * @param string $hrefLang
     */
    function setHrefLang($hrefLang)
    {
        $this->hrefLang = $hrefLang;
    }
    
    /**
     * Gets the base language of the target URI.
     *
     * @return string
     */
    function getHrefLang()
    {
        return $this->hrefLang;
    }
    
    /**
     * Sets the MIME type of the target URI.
     * i.e.: text/css, text/javascript, image/gif.
     *
     * @param string $type
     */
    function setType($type)
    {
        $this->type = $type;
    }
    
    /**
     * Gets the MIME type of the target URI.
     * i.e.: text/css, text/javascript, image/gif.
     * 
     * @return string
     */
    function getType()
    {
        return $this->type;
    }
    
    /**
     * Sets the relationship between the current document and the targeted 
     * document.
     * Valid values: alternate, appendix, bookmark, chapter, contents, 
     * copyright, glossary, help, home, index, next, prev, section, start, 
     * stylesheet, subsection.
     *
     * @param unknown_type $rel
     */
    function setRel($rel)
    {
        $this->rel = $rel;
    }
    
    /**
     * Gets the relationship between the current document and the targeted 
     * document.
     * Valid values: alternate, appendix, bookmark, chapter, contents, 
     * copyright, glossary, help, home, index, next, prev, section, start, 
     * stylesheet, subsection.
     *
     * @return string
     */
    function getRel()
    {
        return $this->rel;
    }
    
    /**
     * Sets the relationship between the targeted document and the current 
     * document.
     * Valid values: alternate, appendix, bookmark, chapter, contents, 
     * copyright, glossary, help, home, index, next, prev, section, start, 
     * stylesheet, subsection.
     * 
     * @param string $rev
     */
    function setRev($rev)
    {
        $this->rev = $rev;
    }
    
    /**
     * Gets the relationship between the targeted document and the current 
     * document.
     * Valid values: alternate, appendix, bookmark, chapter, contents, 
     * copyright, glossary, help, home, index, next, prev, section, start, 
     * stylesheet, subsection.
     * 
     * @return string
     */
    function getRev()
    {
        return $this->rev;
    }
    
    /**
     * Sets the device that will display the document.
     * Valid values: all, braille, print, projection, screen, speech.
     * 
     * @param string $media
     */
    function setMedia($media)
    {
        $this->media = $media;
    }
    
    /**
     * Gets the device that will display the document.
     * Valid values: all, braille, print, projection, screen, speech.
     * 
     * @return string
     */
    function getMedia()
    {
        return $this->getMedia();
    }
    
    // Overriding the toString method for a proper implementation.
    
    /**
     * Returns the string representation for echoing the class atributes.
     *
     * @return string
     */
    function toString()
    {
        $auxString = "<link";
        
        /*
         * Additions of the link own attributes to the return string.
         */
        if (isset($this->charSet)) {
            $auxString = $auxString."charset=\"".$this->charSet."\" ";
        }
        
        if (isset($this->href)) {
            $auxString = $auxString."href=\"".$this->href."\" ";
        }
        
        if (isset($this->hrefLang)) {
            $auxString = $auxString."hreflang=\"".$this->hrefLang."\" ";
        }
        
        if (isset($this->type)) {
            $auxString = $auxString."type=\"".$this->type."\" ";
        }
        
        if (isset($this->rel)) {
            $auxString = $auxString."rel=\"".$this->rel."\" ";
        }
        
        if (isset($this->rev)) {
            $auxString = $auxString."rev=\"".$this->rev."\" ";
        }
        
        if (isset($this->media)) {
            $auxString = $auxString."media=\"".$this->media."\" ";
        }
        
        $auxString = $auxString."/>\n";
        
        return $auxString;
    }
    
}

?>